home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Daemon / OldPatch / MPLockPubPatch.c_4.54 < prev    next >
Text File  |  1998-10-02  |  5KB  |  172 lines

  1. #define DEBUG
  2. #define ADD_DEBUG_CODE
  3. #include <debug.h>
  4.  
  5. #include "MP.h"
  6. #include <extras/macros/exec.h>
  7.  
  8. struct SignalSemaphore LockPubSem;
  9.  
  10. extern struct Process  *MPTask;
  11. extern BYTE   PublicSignal;
  12. extern struct MPSem *MPSem;
  13. extern UBYTE   ModePro[];
  14.  
  15. extern struct Screen * __asm (*OldLockPubScreen)(register __a0 UBYTE *Name,
  16.                                                  register __a6 struct Library *);
  17. extern void __asm (*OldUnlockPubScreen)(register __a0 UBYTE *Name,
  18.                                         register __a1 struct Screen *,
  19.                                         register __a6 struct Library *);
  20.  
  21.  
  22. struct Screen * __saveds __asm NewLockPubScreen(register __a0 UBYTE *Name,
  23.                                                 register __a6 struct IntuitionBase *IBase)
  24. {
  25.   struct OpenNode *on;
  26.   struct Screen *scr, *ps;
  27.   struct DefaultNode *dnode;
  28.   LONG button;
  29.   char tnamebuffer[52];
  30.   char *tname;
  31.   static ULONG stackid=0xc0de0020;
  32.   
  33.   tname=SetupTaskName(tnamebuffer,", LPS",50);
  34.  
  35. DEBUG_CODE(DKP("LockPubScreen(%s)\n",Name););
  36.  
  37.   ps=0;
  38.  
  39.   if(scr=OldLockPubScreen(Name,(struct Library *)IntuitionBase))
  40.   {
  41. DEBUG_CODE(DKP("  RV=0x%08lx\n",ps););
  42.  
  43.     SetTaskName(tname);
  44.     
  45.     return(scr);
  46.   }
  47.   else
  48.   {
  49.     if(strcmp("Workench",Name)) // Can't f with Workbench! //4.53 @1 rewired 
  50.     {
  51.       ObtainSemaphore(&LockPubSem);               //4.53 @11      // 4.54 @1 (comment out)
  52.       if(scr=OldLockPubScreen(Name,(struct Library *)IntuitionBase))
  53.       {
  54. DEBUG_CODE
  55.         (
  56.           DKP("  Second lock attempt succeeded!\n");
  57.           DKP("  RV=0x%08lx\n",ps);
  58.         );
  59.   
  60.         SetTaskName(tname);
  61.   
  62.         ReleaseSemaphore(&LockPubSem);      //4.53 @11    
  63.         
  64.         return(scr);
  65.       }
  66.       else    
  67.       {
  68.         ObtainSemaphoreShared(&MPSem->ListSem);   //4.53 @11 (comment out) // 4.54 @1 (UNcomment out)
  69.         ObtainSemaphore(&MPSem->NodeSem);         //4.53 @11 (comment out) // 4.54 @1 (UNcomment out)
  70.         
  71.         if(dnode=FindDNode(&MPSem->PromotionList[PL_PUBLICSCREENS],Name))
  72.         {
  73.           if(dnode->Flags & DNF_NEVER_PROMOTE)
  74.             dnode=0;
  75.           else
  76.             dnode=DupDNode(dnode);
  77.   
  78.           ReleaseSemaphore(&MPSem->NodeSem);    
  79.         }
  80.         else
  81.         {
  82.           ReleaseSemaphore(&MPSem->NodeSem);    
  83.           if(MPSem->CatchPubScreens)
  84.           {
  85.             if(button=EZReq(0,0,ModePro,GetString(MSG_NEW_PUBSCREEN),GetString(MSG_NEW_PUBSCREEN_BUTTONS),(ULONG)Name))
  86.             {
  87.               if(dnode=AllocDefaultNode(Name))
  88.               {
  89.                 dnode->Type=PL_PUBLICSCREENS;
  90.                 dnode->ModeSelect=2;
  91.                 CloneWB(dnode);
  92.                 dnode=ForceEdit(dnode);
  93.               }   
  94.             }
  95.           }
  96.         }
  97.         
  98.         
  99.         ReleaseSemaphore(&MPSem->ListSem);
  100.         
  101.         ps=0;
  102.         
  103.         if(dnode)
  104.         {
  105.  
  106. DEBUG_CODE(DKP("  Creating new pubscreen %s\n",Name););
  107.           
  108.           FreeVec(dnode->PubName);
  109.           dnode->PubName=Name;
  110.           dnode->PubOptions=1;
  111.       
  112.           if(scr=OpenScreenTags(0, SA_Title                 ,Name,
  113.                                    SA_ModeProNode           ,dnode,
  114.                                    TAG_DONE))
  115.           {
  116.             if(ps=OldLockPubScreen(Name,(struct Library *)IntuitionBase))
  117.             {
  118.               //4.53 @8 now clears ON_OPEN flag
  119.               ObtainSemaphore(&MPSem->OpenListSem);
  120.               if(on=FindOpenNode(ps))
  121.               {
  122.                 // clear the open flag so MP can close the screen
  123.                 on->Flags&=(~ON_OPEN);
  124.               }
  125.               ReleaseSemaphore(&MPSem->OpenListSem);
  126.             }
  127.           }
  128.           
  129.           dnode->PubName=0;
  130.           dnode->PubOptions=0;
  131.           
  132.           FreeDNode(dnode);
  133.         }      
  134.         ReleaseSemaphore(&LockPubSem);
  135.       } // end if(!"workbench")
  136.     }
  137.   }
  138.  
  139. DEBUG_CODE(DKP("  RV=0x%08lx\n",ps););
  140.  
  141.   SetTaskName(tname);
  142.   
  143.   return(ps);
  144. }                          
  145.  
  146.  
  147.  
  148. // 4.53 @9 New patch
  149. void __saveds __asm NewUnlockPubScreen(register __a0 UBYTE *Name, 
  150.                                        register __a1 struct Screen *Scr,
  151.                                        register __a6 struct Library *IBase)
  152. {
  153.   //BOOL signal=0;
  154.   //struct List *plist;
  155.   //struct PubScreenNode *psn;
  156.   //struct OpenNode *on;
  157.   char tnamebuffer[52];
  158.   char *tname;
  159.   static ULONG stack2=0xc0de0021;
  160.   
  161.   tname=SetupTaskName(tnamebuffer,", ULPS",50);
  162.  
  163. DEBUG_CODE(DKP("UnLockPubScreen(%s,0x%08lx)\n",Name,Scr););
  164.  
  165.   OldUnlockPubScreen(Name,Scr,IBase);
  166.  
  167.   // signal MP, birdie kludge
  168.   Signal((struct Task *)MPTask,1<<PublicSignal);
  169.   
  170.   SetTaskName(tname);
  171. }
  172.